<template>
  <div class="storeConfigure">
    <el-form :inline="true" :model="productForm" ref="productForm" class="form-inline">
      <el-form-item label="合同名称">
        <span>{{contractName}}</span>
      </el-form-item><br />
      <el-form-item label="合同编号">
        <span>{{contractNo}}</span>
      </el-form-item><br />
      <el-form-item label="管理费类型">
        <div class="grid-content bg-purple-light">
          <el-select v-model="productForm.manageRebatesType">
            <el-option label="按比例" value="1"></el-option>
            <el-option label="固定额" value="2"></el-option>
          </el-select>
          <span v-if="productForm.manageRebatesType == 1"><el-input class="createStore-inputw" v-model="productForm.manageRebatesRate"></el-input>%</span>
          <span v-if="productForm.manageRebatesType == 2"><el-input class="createStore-inputw" v-model="productForm.manageRebatesRate"></el-input>元/年</span>
        </div>
      </el-form-item><br />
      <el-form-item label="返利方式">
        <div class="grid-content bg-purple-light">
          <el-select v-model="productForm.coinRebatesType">
            <el-option label="按比例" value="1"></el-option>
            <el-option label="商品定额" value="0"></el-option>
            <el-option label="不设置店铺返利比例" value="2"></el-option>
          </el-select><span v-if="productForm.coinRebatesType == 1"><el-input class="createStore-inputw" v-model="productForm.coinRebatesRate"></el-input>%</span>
          <span v-if="productForm.coinRebatesType == 0"><el-input class="createStore-inputw" v-model="productForm.coinRebatesRate"></el-input>元/件</span>
        </div>
      </el-form-item><br />
      <el-form-item>
        <el-button type="primary" @click="configureSubmit">确认</el-button>
        <el-button @click="cancelBtn">取 消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import axios from 'axios'
  export default{
    name: 'storeConfigure',
    data () {
      return {
        productForm: {
          storeSysno: this.$route.params.id,
          manageRebatesRate: '',
          manageRebatesType: '',
          coinRebatesType: '',
          coinRebatesRate: ''
        },
        details: {},
        contractName: '',
        contractNo: ''
      }
    },
    methods: {
      configureSubmit () {
        var params = this.productForm
        axios.post('/api/shop/editShop', params).then((res) => {
          if (res.data.code === 9999) {
            this.$message({
              type: 'success',
              message: '修改店铺配置成功'
            })
            this.$router.push('/storeInfo/' + this.$route.params.id)
          }
        })
      },
      cancelBtn () {
        this.$router.push('/storeInfo/' + this.$route.params.id)
      }
    },
    mounted () {
      axios.post('/api/shop/queryShopDetail', {storeSysno: this.$route.params.id}).then((res) => {
        if (res.data.code === 9999) {
          this.details = res.data.data
          this.contractName = this.details.contractName
          this.contractNo = this.details.contractNo
        }
      })
    }
  }
</script>
<style scoped lang='less'>
  .storeConfigure{
    text-align:center;
    margin-top:100px;
    .createStore-inputw{
      width:45px;
      margin:0 5px;
    }
  }
</style>
